from langchain_core.runnables import RunnableBranch, RunnableLambda


def log(message, value):
    print(message)
    return value + 1


result_chain = RunnableBranch(
    (lambda x: x > 100, lambda x: log("钻石会员", x)),
    (lambda x: 50 <= x <= 100, lambda x: log("高级会员", x)),
    lambda x: log("普通会员", x),
)
print(result_chain)
print(type(result_chain))

result = result_chain.invoke(200)
print(type(result), result)

result = result_chain.invoke(98)
print(type(result), result)

result = result_chain.invoke(13)
print(type(result), result)
